<#include "include/_meta.html">
<title>车辆信息列表</title>
</head>
<body>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="r">共有数据：<strong id="pageTotal">0</strong> 条</span> </div>
	<table id="carListTable" class="table table-border table-bordered table-bg table-hover">
		<thead>
			<tr>
				<th scope="col" colspan="11">车辆信息列表</th>
			</tr>
			<tr class="text-c">
				<th>车牌号码</th>
				<th>车辆颜色</th>
				<th>车辆品牌</th>
				<th>品牌型号</th>
				<th>车辆类型</th>
				<th>自动手动</th>
				<th>车辆状态</th>
				<th>外观类型</th>
				<th>排量大小</th>
				<th>座位数量</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>

		</tbody>
	</table>
</div>

<#include "include/_footer.html">

<script type="text/javascript">

$(function(){

    initTable();
  
});


var initTable = function(){

$('#carListTable').dataTable( {
    	"processing": false,
      	"serverSide": true,
      	"bSort": false,
      	"bFilter":false,
      	"bLengthChange":false,
      	"iDisplayLength":10,
      	"bRetrieve":true,
      	"ajax": {
            "url": "/getcar",
            "data" : {"id" : ${id}},
            "type": "post"
        },
        "columns": [
            { "data": "carcode" },
            { "data": "carcolor" },
            { "data": "carbrand" },
            { "data": "carbrandtype" },
            { "data": "cartype" },
            { "data": "isauto" },
            { "data": "carstate" },
            { "data": "facetype" },
            { "data": "enginesize" },
            { "data": "seatnum" }, 
            { "data": "" }
      	],
      	"columnDefs": [
	        {
		          "targets": [10],
		          "data": "id",
		          "render": function(data, type, full) {
		          		var action_look = "<a style='text-decoration:none' onClick=\"car_look('车辆详细信息','/car-user?id="+full.carid+"','2','800','500')\" href=\"javascript:;\" title=\"详情\"><i class=\"Hui-iconfont\">&#xe665;</i></a>";
		          		
		            	return action_look;
		          }
	        }	        
      	],
      	"fnRowCallback" : function(nRow, aData, iDisplayIndex) { 
      					nRow.className="text-c";    
      					//判断变数箱是自动还是手动
      					if(aData.isauto == 0){
      						$("td:eq(5)",nRow).text("手动");
      					}
      					if(aData.isauto == 1){
      						$("td:eq(5)",nRow).text("自动");
      					}
      					//判断车辆的状态
      					if(aData.carstate == 1){
      						$("td:eq(6)",nRow).text("待审核");
      					}
      					if(aData.carstate == 2){
      						$("td:eq(6)",nRow).text("不合格");
      					} 
      					if(aData.carstate == 3){
      						$("td:eq(6)",nRow).text("已报废");
      					} 
      					if(aData.carstate == 4){
      						$("td:eq(6)",nRow).text("已删除");
      					} 
      					if(aData.carstate == 5){
      						$("td:eq(6)",nRow).text("待上架");
      					} 
      					if(aData.carstate == 6){
      						$("td:eq(6)",nRow).text("待租赁");
      					} 
      					if(aData.carstate == 7){
      						$("td:eq(6)",nRow).text("自用中"); 
      					}  
      					if(aData.carstate == 8){
      						$("td:eq(6)",nRow).text("维修中");
      					} 
      					if(aData.carstate == 9){
      						$("td:eq(6)",nRow).text("保养中");
      					} 
      					if(aData.carstate == 10){
      						$("td:eq(6)",nRow).text("年检中");
      					} 
      					if(aData.carstate == 11){
      						$("td:eq(6)",nRow).text("已租赁");
      					} 
                        return nRow;  
         },
	    "fnDrawCallback": function(oSettings) {
		      //获取后台方式 直接可以拿到json 之后进行处理
		      var json=jQuery.parseJSON(oSettings.jqXHR.responseText);  
		      $("#pageTotal").html(json.recordsTotal);
	    }
  
      	
    });

}

	/*
		参数解释：
		title	标题
		url		请求的url
		id		需要操作的数据id
		w		弹出层宽度（缺省调默认值）
		h		弹出层高度（缺省调默认值）
	*/
	
	//查看车辆详细信息
	function car_look(title,url,id,w,h){
		layer_show(title,url,w,h);
	}



</script>
</body>
</html>